package com.hoongs.v1.controller;

import com.hoongs.v1.entity.Tag;
import com.hoongs.v1.service.TagService;
import com.hoongs.v1.utils.Result;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/tag")
public class TagController {

    @Resource
    private TagService tagService;

    @PostMapping("/save")
    @PreAuthorize("hasAnyAuthority('admin')")
    public Result save(Tag tag) {
        return tagService.save(tag);
    }

    @PostMapping("/add")
    @PreAuthorize("hasAnyAuthority('admin')")
    public Result add(Tag tag) {
        return tagService.add(tag);
    }

    @PostMapping("/remove")
    @PreAuthorize("hasAnyAuthority('admin')")
    public Result remove(String id) {
        return tagService.remove(id);
    }

    @PostMapping("/update")
    @PreAuthorize("hasAnyAuthority('admin')")
    public Result update(Tag tag) {
        return tagService.update(tag);
    }

    @GetMapping("/selectById")
    public Result selectById(String id) {
        return tagService.selectById(id);
    }

    @GetMapping("/selectList")
    public Result selectList(String title, String status) {
        return tagService.selectList(title, status);
    }

    @GetMapping("/selectPageList")
    public Result selectPageList(Integer page, Integer size) {
        return tagService.selectPageList(page, size);
    }

}
